package com.bjb.vr.manager.controller;

import com.alibaba.fastjson.JSONArray;
import com.bjb.vr.common.result.BaseResult;
import com.bjb.vr.common.result.CommonResult;
import com.bjb.vr.manager.service.DataStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 数据统计列表
 *
 * @version 1.0.0
 * @author: HuJingBo
 * @time: 2022/5/9 11:15
 */
@RestController
@RequestMapping("/api/manager/v1")
public class DataStatisticsController {

    @Autowired
    private DataStatisticsService dataStatisticsService;

    /**
     * 统计在线离线设备
     *
     * @return
     */
    @PostMapping("/statistics/devices")
    public BaseResult devicesCount() {
        JSONArray devicesCount = dataStatisticsService.devicesCount();
        return CommonResult.Ok().setResult(devicesCount);
    }

    /**
     * 课程资源统计
     */
    @PostMapping("/statistics/resources")
    public BaseResult resourcesCount() {
        JSONArray resourcesCount = dataStatisticsService.resourcesCount();
        return CommonResult.Ok().setResult(resourcesCount);
    }

    /**
     * 课程热度统计
     */
    @PostMapping("/statistics/resources/useCount")
    public BaseResult resourcesUseCount() {
        JSONArray resourcesUseCount = dataStatisticsService.resourcesUseCount();
        return CommonResult.Ok().setResult(resourcesUseCount);
    }
}
